home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / ham_jg < prev    next >
Internet Message Format  |  1995-03-31  |  16KB

  1. From: James Gentles <jdg@hpqtdla.sqf.hp.com>
  2. Subject:  v04i002:  ham_jg - Ham Radio translations v1.0, Part01/01
  3. Newsgroups: comp.sources.hp48
  4. Followup-To: comp.sys.hp48
  5. Approved: spell@seq.uncwil.edu
  6.  
  7. Checksum: 3795858353 (verify with brik -cv)
  8. Submitted-by: James Gentles <jdg@hpqtdla.sqf.hp.com>
  9. Posting-number: Volume 4, Issue 2
  10. Archive-name: ham_jg/part01
  11.  
  12. BEGIN_RDM ham.rdm
  13. Posted below is a collection of HP48 programs for Radio Amateurs. They are
  14. complete with documentation so it's all self explanitory...
  15.  
  16. Ham_radio:  Various Ham Radio translations, great circle and horizon routines.
  17.  
  18. Comments, or queries to me at the above address.
  19. James
  20. ---------------------------------------------------------------------
  21.       I have no professional connection with Hewlett-Packard's 
  22.     calculator operations other than as a user of their products.
  23. ---------------------------------------------------------------------
  24. Opinions expressed are my own, and are not intended to be an official
  25.               statement by Hewlett-Packard Company
  26. ---------------------------------------------------------------------
  27. To strive, to seek, to find, and not to yield. Tennyson, "Ulysses".
  28. ---------------------------------------------------------------------
  29. James Gentles     Hewlett Packard,    Amateur: GM4WZP
  30. Queensferry Telecoms Division QTD,      Email: jdg@hpsqf.sqf.hp.com 
  31. Station Road,   South Queensferry,     HPDESK: James Gentles / HP1400 
  32. West Lothian, Scotland,  EH30 9XR.      Phone: + 44  31 331 7663  DDI
  33. ---------------------------------------------------------------------
  34. END_RDM
  35.  
  36. BEGIN_DOC ham.doc
  37.                   Radio Amateur Routines for the HP48
  38.                  QRA to Latitude/Longitude CONVERSION,
  39.                   GREAT CIRCLE DISTANCES and HORIZONS
  40.  
  41.                                                            James Gentles
  42.                                                            jdg@hpsqf.sqf.hp.com
  43.                                                            February 1992
  44.  
  45.         1. Introduction
  46.         2. Pseudo Code for Main Routines
  47.         3. HP48 Routines: Descriptions
  48.         4. HP48 Routines: Programs (ASCII DIR Object)
  49.  
  50.  
  51.  
  52. 1. Introduction
  53.  
  54. This file contains a collection of HP48 programs for translating between 
  55. the QRA or Maidenhead locator system used by Radio Amateurs and Lat/Long, 
  56. calculating Great Circle Distances and bearings, and calculating Radio 
  57. Horizons.
  58.  
  59. Also of interest may be a companion set of HP48 routines for performing
  60. Transverse Mercator Projection. This will allow additional translation
  61. between this common mapping projection and Latitude/Longitude. For example,
  62. this is especially useful in the UK, where Amateurs also quote their "WAB"
  63. (Worked All Britain) square, which is based on the "National Grid" which is
  64. a Transverse Mercator Projection.
  65.  
  66. For those interested in coding these routines in other machines I have
  67. included psudo-code descriptions of the main routines. However the main
  68. code that follows is written for the HP48. It was originally written for a
  69. HP28, but has been improved in the process of translation to the HP48. The
  70. code is smaller, faster, and also takes advantage of the HP48's improved
  71. language, e.g. TAGing.
  72.  
  73. 2. Pseudo Code for Main Routines
  74.  
  75. This pseudo-code is based on the following HP48 routines. The pseudo-code uses 
  76. mostly two letter variable names, this does not aid readability, however 
  77. these are the calculator local variables. Leaving the variables like this 
  78. means that no errors have been introduced in the translation to pseudo-code 
  79. from HP48 code.
  80.  
  81.  
  82. Latitude / Longitude to QRA Conversion
  83.  
  84. Note: All calculations in degrees
  85. lo = longitude + 180             offset origin to -180degrees longitude,
  86. La = latitude + 90                       -90degrees latitude.
  87. C1 = ASCII CHAR ('IP(lo/20)+65')
  88. C2 = ASCII CHAR ('IP(la/10)+65')
  89. C3 = ASCII CHAR ('IP(FP(lo/20)*10)+48') 
  90. C4 = ASCII CHAR ('IP(FP(la/10)*10)+48')
  91. C5 = ASCII CHAR ('IP(FP(lo/2)*24)+65')
  92. C6 = ASCII CHAR ('IP(FP(la)*24)+65')
  93. QRA Locator = String C1+C2+C3+C4+C5+C6
  94.  
  95.  
  96. QRA to Latitude / Longitude Conversion
  97.  
  98. First break QRA string into 6 numbers, representing the ASCII number equivilent
  99.     to each of the 6 characters making up the QRA. Call them a b c d e & f.
  100. Latitude  = 'b*10+(d+17)+f/24+1/48-90' 
  101. Longitude = 'a*20+(c+17)*2+e/12+1/24-180'
  102.  
  103.  
  104. Great Circle Calculations.
  105.  
  106. dif = longitute home - longitute away
  107.       (this should be within -180 to +180 degrees)
  108.       (Hint: This number should be non-zero, programs should check for
  109.              this and make dif=0.0001 as a minimum)
  110. lah = latitude of home
  111. laa = latitude of away
  112. ERAD= Radius of the earth (e.g. 6378.388 Km)
  113. dis = 'ACOS(SIN(lah)*SIN(laa)+COS(lah)*COS(laa)*COS(dif))' 
  114. distance = dis /180 *pi *ERAD
  115. angle = 'ACOS((SIN(laa)-SIN(lah)*COS(dis))/(COS(lah)*SIN(dis)))'
  116.  
  117.  
  118. Line of Sight and Radio Horizon Routines
  119.  
  120. ERAD =  6378.388Km (Radius of the Earth in Km) 
  121. Radio Horizon (Km) = SQRT('height*ERAD*8/3')
  122.  
  123. ERAD =  6378.388Km (Radius of the Earth in Km) 
  124. Sight Horizon (Km) = SQRT('height*ERAD*2')
  125.  
  126. 3. HP48 Routines: Descriptions
  127.  
  128. QRA Locator Square Translator: The following procedures translate between 
  129. the worldwide QRA (or ANB or Maidenhead, whatever its called) locator
  130. system used by Radio Amateurs and latitude / longitude.
  131.  
  132. ->QRA   Takes Latitude from stack level 2, and Longitude from level 1
  133.         and returns a string with the Locator. South and West are
  134.         negative. The input should be in DD.MMSS format. For example, 
  135.         take QTH ->QRA gives "IO85HX" for my locator.
  136.  
  137. QRA->   Takes a string from the stack level 1 and returns the Latitude
  138.         in level 2 and Longitude in level 1 of the square center. This
  139.         is the inverse of ->QRA. The output is in DD.MMSS. 
  140.  
  141. Great Circle Distance & Bearings: Calculates the distance between your
  142. station and the remote station, also gives beam heading required.
  143.  
  144. GCIR    Takes the output of QRA-> (Lat and Long) and uses the Lat and 
  145.         Long in QTH to compute the great circle distance and bearing 
  146.         from QTH to the stack Lat and Long. The distance is returned
  147.         in Level 2, in the current units of ERAD. The bearing, in 
  148.         DD.MMSS from north (+E,-W) is returned in Level 1. This program 
  149.         assumes the earth is a perfect sphere ( we all know this is an 
  150.         approximation as the earth is actually flat :-). This program 
  151.         uses the PRESERVE routine given in the HP48 Manual II, page 555
  152.         to ensure flags are preserved after degrees mode is used.
  153.       
  154. QTH     Must contain the two numbers << Lat Long >> representing your
  155.         stations position, in degrees, minutes and seconds.
  156.  
  157. ERAD    Must contain the equatorial radius of the earth. I use:
  158.                       3963.34655611_mi
  159.         which is in miles. Thus the answer to GCIR, HORIZ and LOFS
  160.         will be in miles, You can use the HP48's units management to 
  161.         change this constant if you wish.
  162.  
  163. Radio Horizon: Calculates the flat-band line of sight communication
  164. distance at VHF.
  165.  
  166. HORIZ   Returns the distance between a point on the earth and the
  167.         VHF radio 'horizon' given the height above sea level. The
  168.         height is taken from level 1, and the distance returned in 
  169.         level 1. The height can be in any desired unit, e.g. 3000_ft,
  170.         note however that the answer will always be in the current
  171.         unit associated with ERAD. This allows appropriate units to 
  172.         be used for heights and distances. If the height entered is
  173.         in the base unit of metre's then it does not need the _m 
  174.         suffix. This calculation is NOT the same as the line of sight 
  175.         horizon, as it includes a correction of SQRT(4/3) to allow 
  176.         for tropospheric bending.
  177.  
  178. LOFS    Line of Sight. Same as HORIZ but does not take into account
  179.         any bending, can be used for frequencies above VHF or light.
  180.  
  181. External programs used (included in the listing for completeness):
  182.  
  183. PRESERVE Returns flags to initial state on program exit. Used in GCIR
  184.     routine. See HP48SX Manual II page 555.
  185.  
  186. END_DOC
  187.  
  188. BEGIN_RPL ham.rpl
  189. %%HP: T(3)A(D)F(.);
  190. DIR
  191. \->QRA                                @ Lat & Long to QRA translation
  192.   \<< HMS\-> 180 + SWAP HMS\-> 90 +   @ offset lat/long to "bottom left corner"
  193.   \-> lo la
  194.     \<< lo 20 / IP 65 + CHR 
  195.     la 10 / IP 65 + CHR
  196.     lo 20 / FP 10 * IP 48 + CHR
  197.     la 10 / FP 10 * IP 48 + CHR
  198.     lo 2 / FP 24 * IP 65 + CHR
  199.     la FP 24 * IP 65 + CHR
  200.     \>> + + + + + "QRA" \->TAG
  201.   \>>
  202. QRA\->                                @ QRA to Lat & Long translation
  203.   \<< 1 6 FOR i 
  204.     i PICK i DUP SUB NUM 65 -
  205.     NEXT \-> a b c d e f              @ break string into numerical elements
  206.     \<< DROP 
  207.     b 10 * d 17 + f 24 / 48 INV
  208.     + + + 
  209.     90 - \->HMS "Lat\^o" \->TAG
  210.     a 20 * c 17 + 2 * e 12 / 24 INV 
  211.     + + + 
  212.     180 - \->HMS "Long\^o" \->TAG
  213.     \>>
  214.   \>>
  215. GCIR
  216.   \<<
  217.     \<< DEG HMS\->
  218.     SWAP HMS\-> QTH HMS\->
  219.     SWAP HMS\-> 4 ROLLD
  220.     ROT - DUP
  221.       IF 180 >
  222.       THEN 360 -
  223.       END
  224.       DUP
  225.       IF -180 <
  226.       THEN 360 +
  227.       END
  228.       IF DUP 0 == THEN .0001 + END    @ ensure divisor is non zero
  229.       \-> lh la d
  230.       \<<
  231.       'ACOS(SIN(lh)*SIN(la)+COS(lh)*
  232.       COS(la)*COS(d))' \->NUM 
  233.       DUP 180 / \pi * ERAD * \->NUM 
  234.       SWAP \-> ds
  235.         \<<
  236.         'ACOS((SIN(la)-SIN(lh)*COS(ds))
  237.         /(COS(lh)*SIN(ds)))' \->NUM
  238.         \>>
  239.         IF d 0 > THEN NEG END         @ correction for E or W of N
  240.         \->HMS "\177\^oN" \->TAG
  241.       \>>
  242.     \>> PRESERVE
  243.   \>>
  244. HORIZ
  245.   \<<
  246.   IF DEPTH
  247.   THEN
  248.   ERAD * 8 * 3 / UBASE \v/ ERAD
  249.   CONVERT
  250.   ELSE
  251. "HORIZ
  252. hgt_ \-> dist_"
  253.   DOERR
  254.   END
  255.   \>>
  256. LOFS
  257.   \<<
  258.   IF DEPTH
  259.   THEN ERAD * 2 * UBASE \v/ ERAD
  260.   CONVERT
  261.   ELSE
  262. "LOFS
  263. hgt_ \-> dist_"
  264.   DOERR
  265.   END
  266.   \>>
  267. ERAD                                  @ Radius of the earth in any
  268.   '3963.34655611_mi'                  @ appropriate unit.
  269. QTH                                   @ location of station for
  270.   WZP                                 @ great circle calculations.
  271. WZP
  272.   \<< :Lat\^o: 55.591                 @ data is in D.MMSSsss form.
  273.      :Long\^o: -3.244
  274.   \>>
  275. @
  276. PRESERVE                             @ See HP48SX Manual II page 555.
  277. \<< RCLF \-> f                       @ May be more suitably located in HOME
  278.   \<< EVAL f STOF
  279.   \>>
  280. \>>
  281. END
  282. END_RPL
  283.  
  284.  
  285. BEGIN_ASC ham.asc
  286. %%HP: T(3)A(D)F(.);
  287. "69A20FF7468000000080052554355425655480D9D20E1632916C11C432D6E201
  288. 066E1632EB3A1D6E201066F76C1EF53293632B2130850003075A50530D9D20E1
  289. 632CFA2040C416470B339201000000000195550CFA2050C4F6E6760B33920000
  290. 000000004423993632B213086000301545843084E203075A5057100040542514
  291. 4440ADA20339203001165564336930C2A2090000D69668B01B2130E300040C4F
  292. 4643540D9D20E16323CE2244CF1AFE22D9D2084E204054251444EEDA1ED2A2EE
  293. DA117791473B184E204054251444BD691B21305BF22D9D20C2A2072000C4F464
  294. 35A0867647F502D80246963747F5933A1B21305DF2293632B2130AB0005084F4
  295. 2594A550D9D20E16323CE2244CF1AFE22D9D2084E204054251444EEDA1C53A2E
  296. EDA13F2A250FA117791473B184E204054251444BD691B21305BF22D9D20C2A20
  297. 9200084F42594A5A0867647F502D80246963747F5933A1B21305DF2293632B21
  298. 308C000407434942540D9D20E1632C9432D9D20E1632993C1E3FB1DBBF1E3FB1
  299. 84E2030154584E3FB1DBBF1E3FB1803A20DCF1E0CF190DA178BF13CE22339202
  300. 000000000000810D5CE1AFE22D9D2033920200000000000063090DA1B21305DF
  301. 2278BF13CE22339202000000000000819EBBE1AFE22D9D203392020000000000
  302. 0063076BA1B21305DF223CE2278BF14B2A2279E1AFE22D9D2033920699000000
  303. 000001076BA1B21305DF221C432D6E2020C686D6E2020C616D6E201046E16328
  304. BA20D6E2020C686CA4B1D6E2020C616CA4B1EEDA1D6E2020C686505B1D6E2020
  305. C616505B1EEDA1D6E201046505B1EEDA176BA1F27B1B21304E5A178BF1339202
  306. 00000000000081050FA1DBAA1EEDA184E204054251444EEDA14E5A1DBBF11C43
  307. 2D6E20204637E16328BA20D6E2020C616CA4B1D6E2020C686CA4B1D6E2020463
  308. 7505B1EEDA190DA1D6E2020C686505B1D6E20204637CA4B1EEDA150FA1F27B1B
  309. 21304E5A1EF5323CE22D6E2010464B2A2D5CE1AFE22599A15DF22E1FB1C2A20B
  310. 00001B0BE4EB522EF53293632B213084E2080052554355425655493632B21308
  311. 330040152514D840D9D20E16329C2A2233A20A132D6E201096D6E201096A9CF1
  312. D6E20109678BF1C58C164BC133920100000000000056090DA1C42321C432D6E2
  313. 01016D6E201026D6E201036D6E201046D6E201056D6E201066E16328DBF1D6E2
  314. 01026339201000000000000010EEDA1D6E20104633920100000000000071076B
  315. A1D6E20106633920100000000000042050FA1339201000000000000840872B17
  316. 6BA176BA176BA133920100000000000009090DA1E1FB1C2A20D0000C416470BE
  317. B522D6E201016339201000000000000020EEDA1D6E2010363392010000000000
  318. 0071076BA1ED2A2EEDA1D6E20105633920100000000000021050FA1339201000
  319. 000000000420872B176BA176BA176BA133920200000000000081090DA1E1FB1C
  320. 2A20F0000C4F6E6760BEB522EF53293632B21303620040D815251440D9D20E16
  321. 32E3FB133920200000000000081076BA1DBBF1E3FB1339201000000000000090
  322. 76BA11C432D6E2020C6F6D6E2020C616E1632D6E2020C6F63392010000000000
  323. 0002050FA1D6BB133920100000000000056076BA166BC1D6E2020C6163392010
  324. 0000000000001050FA1D6BB133920100000000000056076BA166BC1D6E2020C6
  325. F633920100000000000002050FA13ABB1339201000000000000010EEDA1D6BB1
  326. 33920100000000000084076BA166BC1D6E2020C6163392010000000000000105
  327. 0FA13ABB1339201000000000000010EEDA1D6BB133920100000000000084076B
  328. A166BC1D6E2020C6F6ED2A250FA13ABB1339201000000000000420EEDA1D6BB1
  329. 33920100000000000056076BA166BC1D6E2020C6163ABB133920100000000000
  330. 0420EEDA1D6BB133920100000000000056076BA166BC1EF53276BA176BA176BA
  331. 176BA176BA1C2A20B0000152514EB52293632B2130F750"
  332. END_ASC
  333.  
  334.  
  335. BYTES: #57Fh 1436.5
  336.  
  337. BEGIN_UU ham.uue
  338. begin 644 ham
  339. M2%!(4#0X+466*O!_9`@````(4%)%4T525D4(G2W@82,9QA%,(VTN$&#F82.^Z
  340. MH]'F`@%F?\;A7R,Y-K(2`U@`,'"E!370V0(>-L*O`@1,872P,RD0`````!!9W
  341. M5<"O`@5,;VYGL#,I````````1#*98R,K,8`&``-15$@#2"XP<*4%=0$`!$52,
  342. M040$VBHPDP(#$&%51C.6`RPJD```;6F&"[$2`SX`0,#T9#1%T-D"'C8R[")$X
  343. M_*'O(ITM@.0"!$52043NK>$M*NZM$7<9=+.!Y`($15)!1-N6L1(#M2_2V0(LK
  344. M*G`"`$Q/1E,*:&=T7R"-(&1I<W1?.:.Q$@/5+Y)C(RLQH`L`!4A/4DE:!9TM8
  345. MX&$CPRY"Q!_Z+M+9`D@N0%`D%43DWAI<H^+>&O.B4O`:<9=!-QM(+D!0)!5$;
  346. MM&T9*S%0^R*=+<"B`BD`@/0DE:2E@'9&]P72"$*6-D?WE3,:*S%0_2(Y-K(2P
  347. M`\@`0'`TE"1%T-D"'C;"22.=+>!A(YG#X?,;O?OA\QM(+C`0187D\QN]^^'S%
  348. M&PBC`LT?#OR1T!J'^S'L(C,I(````````!C0Q1[Z+M+9`C,I(````````#:0U
  349. MT!HK,5#](H?[,>PB,RD@````````&.F['OHNTMD",RD@````````-G"V&BLQL
  350. M4/TBPRYRN!^THB*7'OHNTMD",RE@F0``````$'"V&BLQ4/TBP332Y@(";&AM9
  351. M+B#`%M;F`@%D'C:"JP)M+B#`AL9*&VTN(,`6QDH;[JW1Y@(";&@%M='F`@)LD
  352. M806UX=X:;2X00%90&^ZM<;8:+[>Q$@/DI7&X'S,I(````````!A0\!J]JN'>5
  353. M&D@N0%`D%43DWAKDI=&['\$TTN8"`F1S'C:"JP)M+B#`%L9*&VTN(,"&QDH;\
  354. M;2X@0#974!ONK9'0&FTN(,"&5E`;;2X@0#;'2AONK5'P&B^WL1(#Y*7A7R/#0
  355. M+M+F`@%DM*+2Q1[Z+E*9&M4OXO$;+"JP``"QL$Z^)>)?(SDVLA(#2"Z``"55$
  356. M-%4D95648R,K,8`S``114D&-!)TMX&$CR:(B,RJ@,=+F`@%I;2X0D*;)'VTN#
  357. M$)!VN!]<R&&T'#,I$````````&60T!I,,A),(VTN$!#6Y@(!8FTN$##6Y@(!;
  358. M9&TN$%#6Y@(!9AXV@KT?;2X0(#:3`@$````````![JW1Y@(!9#,I$```````!
  359. M`!=PMAIM+A!@-I,"`0``````0`(%KS&3`@$``````(`$>+)QMAIGJW&V&C,I3
  360. M$````````)"0T!H>O\&B`@T`P!1&!^M;(FTN$!`VDP(!`````````NZMT>8"Y
  361. M`6,S*1`````````7<+8:WJ+BWAIM+A!0-I,"`0``````(`$%KS&3`@$`````9
  362. M`$`">+)QMAIGJW&V&C,I(````````!B0T!H>O\&B`@\`P/3F=@;K6R+^-9)C%
  363. M(RLQ,"8`!(U14D$$G2W@82,^OS&3`@(``````(`!9ZO1NQ\^OS&3`@$`````'
  364. M```)9ZL13"-M+B#`]M;F`@)L81XVTN8"`FQO,RD0````````(%#P&FV[,9,"S
  365. M`0``````4`9GJV&V'&TN(,`6-I,"`0````````$%K]&V&S,I$````````&5P7
  366. MMAIFR]'F`@)L;S,I$````````"!0\!JCNS&3`@$````````![JW1MALS*1``&
  367. M``````!(<+8:9LO1Y@(";&$S*1`````````04/`:H[LQDP(!`````````>ZML
  368. MT;8;,RD0````````2'"V&F;+T>8"`FQOWJ)2\!JCNS&3`@$``````$`"[JW1@
  369. MMALS*1````````!E<+8:9LO1Y@(";&&CNS&3`@$``````$`"[JW1MALS*1``2
  370. J``````!E<+8:9LOA7R-GJW&V&F>K<;8:9ZO!H@(+`!`E%>1;(CDVLA(#\
  371. ``
  372. end
  373. END_UU
  374.